#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef pair<int, int> PII;
queue<PII> q;
int dx[8] = {-2, -2, -1, 1, 2, 2, 1, -1};
int dy[8] = {1, -1, -2, -2, -1, 1, 2, 2};
int main() {
    int n, m;
    int x, y;
    cin >> n >> m;
    cin >> x >> y;
    vector<vector<int>> nums(n + 1, vector<int>(m + 1, -1));
    vector<vector<int>> flag(n + 1, vector<int>(m + 1, 1));
    q.push({x, y});
    nums[x][y] = 0;
    while(!q.empty()) {
        auto& [a, b] = q.front();
        q.pop();
        for(int i = 0; i < 8; i++) {
            int row = a + dx[i], col = b + dy[i];
            if(row >= 1 && row <= n && col >= 1 && col <= m && nums[row][col] == -1 && flag[row][col] == 1) {
                q.push({row, col});
                nums[row][col] = nums[a][b] + 1;
                flag[row][col] = 0;
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++) {
            cout << nums[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}